package eip.chapter4.guaranteed;

public enum GroceryItem {
	
	Bread, RedPepper, Lettuce, Caviar, Lobster, Tenderloin;
	
	public static final String XML_RED_PEPPER = "Red Pepper";
	
	public static GroceryItem deserialize(String groceryItem) {
		if(XML_RED_PEPPER.equals(groceryItem)) {
			return GroceryItem.RedPepper;
		} else {
			return GroceryItem.valueOf(groceryItem);
		}
	}
	
	public static String serialize(GroceryItem groceryItem) {
		if(groceryItem.equals(GroceryItem.RedPepper)) {
			return XML_RED_PEPPER;
		} else {
			return groceryItem.toString();
		}
	}
}
